home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
treadmilChar.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
3KB
|
113 lines
-- treadmil character state machine
beginStateMachine()
onEnter(function(msg)
local treadmill = getStateObjectFromID(msg.sender);
storeStateObject("treadmill", treadmill);
if (treadmill) then
-- treadmill does still exist
if (getParent().isOneActionPointLocked(treadmill)) then
-- action point is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
getParent().lockActionPoints(treadmill);
end
else
-- treadmill does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
end )
onExit(function(msg)
-- local treadmill = retrieveStateObject("treadmill");
-- getParent().stopAllActivities(treadmill);
-- getParent().unlockActionPoints(treadmill);
-- removeStateObject("treadmill");
unlockAll("treadmill");
end )
-- enter the treadmil
state("enter")
onEnter(function(msg)
startAnimation("treadmilStart");
sendDelayedMsgThis("startTreadmilSound", 3000);
end )
onMsg("startTreadmilSound", function(msg)
getParent().playSound("treadmilOn");
getParent().playSound("treadmilFadein");
sendDelayedMsg("startTreadmilLoopSound", this, 3430);
end )
onMsg("startTreadmilLoopSound", function(msg)
getParent().loopSound("treadmilLoop");
end )
onMsg("end", function(msg)
if (testCancel()) then
setState("exit");
else
setState("run");
end
end )
-- run on treadmil
state("run")
onEnter(function(msg)
local treadmill = retrieveStateObject("treadmill");
local run = getParent().startActivity("run", treadmill);
length, scale = getActivityLength(run);
storeData("scale", scale);
print("run scale:" .. scale);
startAnimation("treadmilLoop", false, scale);
sendDelayedMsgThis("stopRun", length);
end )
onMsg("startTreadmilLoopSound", function(msg)
getParent().loopSound("treadmilLoop");
end )
onMsg("stopRun", function(msg)
print("stopRun timeout");
setState("exit");
end )
onMsg("end", function(msg)
if testCancel() or (not this.getParent().getCurrentActivityGain()) then
print("stopRun getCurrentActivityGain");
setState("exit");
else
startAnimation("treadmilLoop", false, retrieveData("scale", 1.0));
--doSomething();
end
end )
-- exit the treadmill
state("exit")
onEnter(function(msg)
--print("exit the treadmill");
startAnimation("treadmilExit", false, retrieveData("scale", 1.0));
getParent().stopSound("treadmilLoop");
getParent().playSound("treadmilFadeout");
local treadmill = retrieveStateObject("treadmill");
getParent().stopAllActivities(treadmill);
end )
onMsg("end", function(msg)
setCurrentPosition();
exitStateMachine();
end )
endStateMachine()